package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.PointsPackage;
import com.hello.system.service.IPointsPackageService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 积分充值套餐Controller
 * 
 * @author hello
 * @date 2025-10-29
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/pointsPackage")
public class PointsPackageController extends BaseController
{
    private final IPointsPackageService pointsPackageService;

    /**
     * 查询积分充值套餐列表
     */
    @RequiresPermissions("system:pointsPackage:list")
    @GetMapping("/list")
    public TableDataInfo list(PointsPackage pointsPackage)
    {
        startPage();
        List<PointsPackage> list = pointsPackageService.selectPointsPackageList(pointsPackage);
        return getDataTable(list);
    }

    /**
     * 导出积分充值套餐列表
     */
    @RequiresPermissions("system:pointsPackage:export")
    @Log(title = "积分充值套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PointsPackage pointsPackage)
    {
        List<PointsPackage> list = pointsPackageService.selectPointsPackageList(pointsPackage);
        ExcelUtil<PointsPackage> util = new ExcelUtil<PointsPackage>(PointsPackage.class);
        util.exportExcel(response, list, "积分充值套餐数据");
    }

    /**
     * 获取积分充值套餐详细信息
     */
    @RequiresPermissions("system:pointsPackage:query")
    @GetMapping(value = "/{packageId}")
    public AjaxResult getInfo(@PathVariable("packageId") Long packageId)
    {
        return success(pointsPackageService.selectPointsPackageByPackageId(packageId));
    }

    /**
     * 新增积分充值套餐
     */
    @RequiresPermissions("system:pointsPackage:add")
    @Log(title = "积分充值套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PointsPackage pointsPackage)
    {
        return toAjax(pointsPackageService.insertPointsPackage(pointsPackage));
    }

    /**
     * 修改积分充值套餐
     */
    @RequiresPermissions("system:pointsPackage:edit")
    @Log(title = "积分充值套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PointsPackage pointsPackage)
    {
        return toAjax(pointsPackageService.updatePointsPackage(pointsPackage));
    }

    /**
     * 删除积分充值套餐
     */
    @RequiresPermissions("system:pointsPackage:remove")
    @Log(title = "积分充值套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageIds}")
    public AjaxResult remove(@PathVariable Long[] packageIds)
    {
        return toAjax(pointsPackageService.deletePointsPackageByPackageIds(packageIds));
    }
}
